﻿<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="Friends List Example">
    <Require feature="opensocial-0.7" />
  </ModulePrefs>
  <Content type="html">

    <![CDATA[
     			 <script type="text/javascript">

  function getData() {    
    var req = opensocial.newDataRequest(); 
     req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER), 'viewer');
    req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS), 'viewerFriends');
    req.send(onLoadFriends);
  };
   function onLoadFriends(dataResponse) {
   		 var viewer = dataResponse.get('viewer').getData();
   		 var html = 'Friends of ' + viewer.getDisplayName(); 
   		 html += ':<br><ul>';
   		 var viewerFriends = dataResponse.get('viewerFriends').getData();
   		 viewerFriends.each(function(person) {
     		 	html += '<li>' + person.getDisplayName() + '</li>';
   		 });
   		 html += '</ul>';
   		 document.getElementById('message').innerHTML = html;
 	 };
      gadgets.util.registerOnLoadHandler(getData);
  </script>
  <div id="message"> </div>
   			]]>
  </Content>
</Module>
